﻿using CRM.Admin.Contracts.Contract.Customer;
using CRM.Admin.Contracts.Model.Map;
using KingsSharp.Core;
using KingsSharp.Core.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CRM.Admin.Contracts.Dto.Customer;
using KingsSharp.Common.Data;
using KingsSharp.Common;

namespace CRM.Admin.Services.Service.Customer
{
    /// <summary>
    /// 简介
    /// </summary>
    public  class AreaProfilesService:ServiceBase,IAreaProfilesService
    {
        private IRepository<AreaProfilesInfo, Guid> AreaProfilesRepository;
        public AreaProfilesService(IRepository<AreaProfilesInfo, Guid> _AreaProfilesRepository)
            :base(_AreaProfilesRepository.UnitOfWork)
        {
            AreaProfilesRepository = _AreaProfilesRepository;
        }

        public IQueryable<AreaProfilesInfo> AreaProfiles
        {
            get
            {
                return AreaProfilesRepository.Entities;
            }
        }
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="dtos"></param>
        /// <returns></returns>
        public OperationResult Insert(params AreaProfilesDto[] dtos)
        {
            dtos.CheckNotNull("dtos");
            foreach (var t in dtos)
            {
                t.Id = Guid.NewGuid();
                t.CreateTime = DateTime.Now;
            }
            var result = AreaProfilesRepository.Insert(dtos);
            return result;
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="dtos"></param>
        /// <returns></returns>
        public OperationResult Update(params AreaProfilesDto[] dtos)
        {
            dtos.CheckNotNull("dtos");
            var result = AreaProfilesRepository.Update(dtos);
            return result;
        }
    }
}
